package com.ruoyi.expensereimbursement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.expensereimbursement.domain.ReimbursementPaymentApplication;
import com.ruoyi.expensereimbursement.service.IReimbursementPaymentApplicationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 支付申请Controller
 * 
 * @author ruoyi
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/paymentapplication")
public class ReimbursementPaymentApplicationController extends BaseController
{
    @Autowired
    private IReimbursementPaymentApplicationService reimbursementPaymentApplicationService;

    /**
     * 查询支付申请列表
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:list")
    @GetMapping("/list")
    public TableDataInfo list(ReimbursementPaymentApplication reimbursementPaymentApplication)
    {
        startPage();
        List<ReimbursementPaymentApplication> list = reimbursementPaymentApplicationService.selectReimbursementPaymentApplicationList(reimbursementPaymentApplication);
        return getDataTable(list);
    }

    /**
     * 导出支付申请列表
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:export")
    @Log(title = "支付申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReimbursementPaymentApplication reimbursementPaymentApplication)
    {
        List<ReimbursementPaymentApplication> list = reimbursementPaymentApplicationService.selectReimbursementPaymentApplicationList(reimbursementPaymentApplication);
        ExcelUtil<ReimbursementPaymentApplication> util = new ExcelUtil<ReimbursementPaymentApplication>(ReimbursementPaymentApplication.class);
        util.exportExcel(response, list, "支付申请数据");
    }

    /**
     * 获取支付申请详细信息
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:query")
    @GetMapping(value = "/{paymentApplicationId}")
    public AjaxResult getInfo(@PathVariable("paymentApplicationId") Long paymentApplicationId)
    {
        return success(reimbursementPaymentApplicationService.selectReimbursementPaymentApplicationByPaymentApplicationId(paymentApplicationId));
    }

    /**
     * 新增支付申请
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:add")
    @Log(title = "支付申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReimbursementPaymentApplication reimbursementPaymentApplication)
    {
        return toAjax(reimbursementPaymentApplicationService.insertReimbursementPaymentApplication(reimbursementPaymentApplication));
    }

    /**
     * 修改支付申请
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:edit")
    @Log(title = "支付申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReimbursementPaymentApplication reimbursementPaymentApplication)
    {
        return toAjax(reimbursementPaymentApplicationService.updateReimbursementPaymentApplication(reimbursementPaymentApplication));
    }

    /**
     * 删除支付申请
     */
    @RequiresPermissions("expensereimbursement:paymentapplication:remove")
    @Log(title = "支付申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentApplicationIds}")
    public AjaxResult remove(@PathVariable Long[] paymentApplicationIds)
    {
        return toAjax(reimbursementPaymentApplicationService.deleteReimbursementPaymentApplicationByPaymentApplicationIds(paymentApplicationIds));
    }
}
